PROJECT=vm1

OPTIMIZATION=-o3  -msse
DIRS_INCLUDE=-Iinclude

DIRS_LIB_STATIC=-Llib/static
DIRS_LIB_DYNAMIC=-Iinclude -Llib/dynamic

DIRS_LIB=$(DIRS_LIB_DYNAMIC) $(DIRS_LIB_STATIC)

LIBS_BOOST_STATIC=#-lboost_thread
LIBS_BOOST_DYNAMIC=#-lboost_thread.so
LIBS_MISC=-lpthread
MISC_OPTIONS=

WARNING_OPTIONS=-Wall

DEBUG_OPTIONS=    -g $(DIRS_INCLUDE)                 $(WARNING_OPTIONS)  $(MISC_OPTIONS)
#RELEASE_OPTIONS=    $(DIRS_INCLUDE)                 $(WARNING_OPTIONS)  $(MISC_OPTIONS)
RELEASE_OPTIONS=     $(DIRS_INCLUDE) $(OPTIMIZATION) $(WARNING_OPTIONS)  $(MISC_OPTIONS)

CC=mpicc
############################################################################
All: Init 1a 1b 2a 2b
# ===========================================
obj/1a/main.o: src/gvozdarev_1a.c
	$(CC)  -c  $(RELEASE_OPTIONS)   src/gvozdarev_1a.c                 -o obj/1a/main.o
bin/1a:  obj/1a/main.o
	$(CC)     $(RELEASE_OPTIONS)  $(DIRS_LIB)     obj/1a/*.o                      -o  bin/1a

1a: bin/1a
# -------------------------------
obj/1b/main.o: src/gvozdarev_1b.c
	$(CC)  -c  $(RELEASE_OPTIONS)   src/gvozdarev_1b.c                 -o obj/1b/main.o
bin/1b:  obj/1b/main.o
	$(CC)     $(RELEASE_OPTIONS)  $(DIRS_LIB)     obj/1b/*.o                      -o  bin/1b

1b: bin/1b
# -------------------------------
obj/2a/main.o: src/gvozdarev_2a.c
	$(CC)  -c  $(RELEASE_OPTIONS)   src/gvozdarev_2a.c                 -o obj/2a/main.o
bin/2a:  obj/2a/main.o
	$(CC)     $(RELEASE_OPTIONS)  $(DIRS_LIB)     obj/2a/*.o                      -o  bin/2a

2a: bin/2a
# -------------------------------
obj/2b/main.o: src/gvozdarev_2b.c
	$(CC)  -c  $(RELEASE_OPTIONS)   src/gvozdarev_2b.c                 -o obj/2b/main.o
bin/2b:  obj/2b/main.o
	$(CC)     $(RELEASE_OPTIONS)  $(DIRS_LIB)     obj/2b/*.o                      -o  bin/2b

2b: bin/2b
# ===========================================
obj/gen_array/main.o: src/gen_array.cpp
	g++ -c    $(RELEASE_OPTIONS)   src/gen_array.cpp                   -o obj/gen_array/main.o
bin/gen_array: obj/gen_array/main.o
	g++       $(RELEASE_OPTIONS)                  obj/gen_array/*.o    -o bin/gen_array 

gen_array: bin/gen_array

# ===========================================
Test: Init All test_1a test_1b test_2a test_2b

# ------------------------------
test_1a: 1a
	perl test_1a.pl --from 1 --to 150000 --step 1000  2>logs/test_1a.ERR
# ------------------------------
test_1b: 1b
	perl test_1b.pl --proc_num 16 --mess_num 10000    2>logs/test_1b.ERR
# ------------------------------
test_2a: 2a gen_array
	perl test_2.pl -f 2a 2>logs/test_2a.ERR
# ------------------------------
test_2b: 2b gen_array
	perl test_2.pl -f 2b 2>logs/test_2b.ERR

# ===========================================
Clean:
	rm -rf bin/*
	rm -rf obj/*
	rm -rf stats/*
	rm -rf logs/*
# -----------------------------
Init:
	mkdir -p bin/
	mkdir -p obj/1a obj/1b obj/2a obj/2b obj/gen_array
	mkdir -p stats/
	mkdir -p logs/
#	link simple_matrix.txt bin/Release/matrix.txt
#	link simple_data.txt bin/vm2/data.txt
#	link config.json bin/Release/config.json
#	link config.json bin/Debug/config.json
############################################################################
